<?php
namespace frontend\models;
use yii\base\Model;
use common\models\PreAdminArticle;


/*
**Team :
**Coding by 曾钰媛 1511240 170703
**This is the post form
*/
class PostForm extends Model
{
	public $article_id;
    public $aid;
    public $article_label;
    public $article_text;
    public $post_time;
    public $update_time;
    public $status;
    public $article_title;
	
	public $_lastError= "";
	
	public function rules()
	{
		return [
		[['aid','article-text','article_title'],'required'],
		];
	}
	
	public function attributeLabels(){
		return[
		'article_id'=>'文章编号',
		'article-text'=>'文章内容',
		'article_label'=>'标签',
		'article_title'=>'标题',
		];
		
	}
	
	public static function getList($cond,$curPage=1,$pageSize =5 ,$orderBy =['article_id'=>SORT_DESC])
	{
		$model = new PreAdminArticle();
		$select =['article_id','article_title','article_label','aid',
		'article_text','post_time','update_time','status'
		];
		$query=$model->find()
		->select($select)
		->where($cond)
		->orderBy($orderBy);
		
		$res =$model->getPages($query,$curPage,$pageSize);
		//$res['data']=self::_formatList($res['data']);
		return $res;
	}
		
		
		
    /*public static function _formateList($data)
	{
		foreach($data as &$list){
			$list['tags']=[];
			if(isset($list['relate']))
		}
	}*/
}